<template>
	<!-- <view class="container" :style="{paddingTop:tH}">
		<view class="headerTit" :style="{height:tH,paddingTop:pT}">
			泗河基地
		</view> -->
		<sys-container :label="'友卓消易云'" withoutTop="true" >
			<template v-slot:content >
				<view class="warp">
					<scroll-view class="selectList" scroll-y="true" @scrolltolower="nextPage" lower-threshold="10">
						<view class="cardList">
							<view class="card"  v-for="(item,index) in list" :key="index" @tap="selected(item)">
								<view class="tit">
									<van-tag color="#E70012">选择题</van-tag>
									<view class="taskName">
											   {{item.title}}
									</view>
								</view>
								<view class="otherInfo">
									<u-grid gutter="20" :border="false">
										<u-grid-item>
											<view class="date">
												<image src="@/static/images/icon/icon-clock.png" style="width:23rpx;height:23rpx;margin-right:10rpx" mode="widthFix"></image>
												<text>{{item.formatDate}}</text>
											</view>
											
										</u-grid-item>
										<u-grid-item>
											
											<text>题目数量：{{item.item_number}}道</text>
										</u-grid-item>
										<u-grid-item>
											
											<text>答题人数：{{item.answer}}人</text>
										</u-grid-item>
									</u-grid>
								</view>
							</view>
							<!-- <view class="card" @tap="selected">
								<view class="tit">
									<van-tag color="#E70012">选择题</van-tag>
									<view class="taskName">
											   中级消防监控理论试题
									</view>
								</view>
								<view class="otherInfo">
									<van-row gutter="20">
										<van-col>
											<view class="date">
												<image src="@/static/images/icon/icon-clock.png" style="width:23rpx;height:23rpx;margin-right:10rpx" mode="widthFix"></image>
												<text>2023-08-28 08:35:50</text>
											</view>
											
										</van-col>
										<van-col>
											
											<text>题目数量：120道</text>
										</van-col>
										<van-col>
											
											<text>答题人数：1300人</text>
										</van-col>
									</van-row>
								</view>
							</view> -->
						</view>
					</scroll-view>
					</view>
			</template>
		
		</sys-container>
		
	<!-- </view> -->
</template>
<script>
	import{practiceList} from '@/globalApi/requestApi.js'
	import {formatTime} from '@/util/index.js'
	export default {
		components:{
			
			// sysContainer
		},
		data() {
			return {
				list:[],
				params:{
					tid:'',
					type:'',
					page:1,
					limit:10
				}
			}
		},
		onLoad(options) {
			this.params.tid = options.tid
			this.params.type = options.type
		},
		onShow() {
			this.params.page=1
			this.list = []
			this.initPage()
		},
		methods: {
			initPage(){
				var res = this.getPage().then(res=>{
					if(res.code==200){
						if(res.data.length==0){
							uni.showToast({
								title:'暂无更多数据',
								icon:'none'
							})
							return
						}
						if(res.data.length>0){
							this.list = [...this.list,...res.data]
							this.list.forEach(item=>{
								item.formatDate = formatTime(item.add_time,'yyyy-MM-dd HH:mm:ss')
							})
							
						}
					}
					
				})
			},
			async getPage(){
				var res = await practiceList(this.params)
				return res
			},
			nextPage(){
				this.params.page+=1
				this.initPage()
			},
			selected(data){
				uni.navigateTo({
					url:'../testInfo/testInfo?data='+JSON.stringify(data)
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.warp{
		height:100%;
		width:100%;
		background:#f8f8f8;
		overflow:hidden;
		.card{
			width:100%;
			padding:33rpx 47rpx;
			box-sizing: border-box;
			background:#fff;
			margin:22rpx 0;
			.tit{
				display: flex;
				align-items: center;
				justify-content: flex-start;
				.taskName{
					margin-left:16rpx;
					font-size: 30rpx;
					font-weight: 400;
					color: #222222;
				}
			}
			.otherInfo{
				font-size: 20rpx;
				font-weight: 400;
				color: #666666;
				margin-top:41rpx;
				.date{
					display: flex;
					align-items: center;
				}
				
			}
		}
	}
	
	
</style>
